﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T2_garage;
using System.Threading;
using System.Windows.Forms;


namespace T2_garage
{
    class Communication
    {
        public void parkSpot(int place)
        {
            
                switch (place)
                {
                    case 1:
                        Vm110.SetDigitalChannel(3);
                        Vm110.SetDigitalChannel(1);
                        break;
                    case 2:
                        Vm110.SetDigitalChannel(4);
                        Vm110.SetDigitalChannel(1);
                        break;
                    case 3:
                        Vm110.SetDigitalChannel(3);
                        Vm110.SetDigitalChannel(4);
                        Vm110.SetDigitalChannel(1);
                        break;
                    case 4:
                        Vm110.SetDigitalChannel(5);
                        Vm110.SetDigitalChannel(3);
                        Vm110.SetDigitalChannel(1);
                        break;
                    case 5:
                        Vm110.SetDigitalChannel(5);
                        Vm110.SetDigitalChannel(4);
                        Vm110.SetDigitalChannel(1);
                        break;
                    case 6:
                        Vm110.SetDigitalChannel(5);
                        Vm110.SetDigitalChannel(4);
                        Vm110.SetDigitalChannel(3);
                        Vm110.SetDigitalChannel(1);
                        break;
                    default:
                        break;

                }
            
        }

        public void fetchSpot(int place)
        {
            switch (place)
            {
                case 1:
                    Vm110.SetDigitalChannel(3);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                case 2:
                    Vm110.SetDigitalChannel(4);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                case 3:
                    Vm110.SetDigitalChannel(4);
                    Vm110.SetDigitalChannel(3);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                case 4:
                    Vm110.SetDigitalChannel(5);
                    Vm110.SetDigitalChannel(3);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                case 5:
                    Vm110.SetDigitalChannel(5);
                    Vm110.SetDigitalChannel(4);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                case 6:
                    Vm110.SetDigitalChannel(5);
                    Vm110.SetDigitalChannel(4);
                    Vm110.SetDigitalChannel(3);
                    Vm110.SetDigitalChannel(2);
                    Vm110.SetDigitalChannel(1);
                    break;
                default:
                    break;
            }
        }

        public bool checkEntrance()
        {
            if (!Vm110.ReadDigitalChannel(1))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool checkExit()
        {
            if (Vm110.ReadDigitalChannel(2))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    }
}
